package com.wzj.uarmor.controller;

import com.wzj.uarmor.domain.Device;
import com.wzj.uarmor.query.DeviceQuery;
import com.wzj.uarmor.service.IDeviceService;
import com.wzj.uarmor.utils.ResponseVO;
import com.wzj.uarmor.utils.ResultUtil;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import java.util.List;


/**
 * 设备管理（新）
 * @author whong
 * @date 2023/03/18
 */
@RestController
@RequestMapping("/device")
@RequiredArgsConstructor
public class DeviceController {

    private final IDeviceService deviceService;

    /**
     * 获取设备列表
     *
     * @return
     */
    @GetMapping("/list")
    public ResponseVO list() {
        List<Device> deviceList = deviceService.list();
        return ResultUtil.vo(deviceList);

    }

    /**
     * 移除设备
     * @param deviceQuery 设备参数
     * @return {@link ResponseVO}
     */
    @PostMapping("/delete")
    public ResponseVO delete(@RequestBody DeviceQuery deviceQuery) {
        // 拔出U盘删除
        /*if (type) {
            //正常移除
            return ResultUtil.vo(200, "", "");
        }*/
        //
        deviceService.removeById(deviceQuery.getId());
        return ResultUtil.vo(200, "删除成功");
    }
}
